
/*
*
*	The Gimme ECMAScript Library by Stephen Stchur
*	"Taking the pain out of Javascript!"
*
*	Copyright (c) Microsoft Corporation.  All rights reserved.
*
*/

Gimme.Screen = new function()
{
	function getViewportSize()
	{
		var size = { width: 0, height: 0 };
		if (typeof window.innerWidth !== 'undefined')
		{
			size = { width: window.innerWidth, height: window.innerHeight };
		}
		else if (typeof document.documentElement !== 'undefined' && typeof document.documentElement.clientWidth !== 'undefined' && document.documentElement.clientWidth !== 0)
		{
			size = { width: document.documentElement.clientWidth, height: document.documentElement.clientHeight };
		}
		else
		{
			size = { width: document.getElementsByTagName('body')[0].clientWidth, height: document.getElementsByTagName('body')[0].clientHeight };
		}

		return size;
	}
	this.get_viewport_size = getViewportSize;
	//[AltSyntax]this.getViewportSize = getViewportSize;

	function getMousePos(_evt)
	{
		_evt = _evt || window.event;

		var cursorPos = { x: 0, y: 0 };

		// Standard way of obtaining cursor position relative to the entire page is via .pageX and .pageY.		
		if (typeof _evt.pageX !== 'undefined')
		{
			cursorPos.x = _evt.pageX;
			cursorPos.y = _evt.pageY;
		}
		else
		{
			// The .clientX/Y properties measure the distance from the mouse cursor to the edges of the browser window.  In order to find the
			// mouse position relative to the entire page, we need to add scroll position to their values.			
			var scrollPos = this.get_scroll_pos();
			cursorPos.x = _evt.clientX + scrollPos.x;
			cursorPos.y = _evt.clientY + scrollPos.y;
		}

		return cursorPos;
	}
	this.get_mouse_pos = getMousePos;
	//[AltSyntax]this.getMousePosition = getMousePos;

	function getScrollPos()
	{
		return Gimme(window).get_scroll_pos();
	}
	this.get_scroll_pos = getScrollPos;
	//[AltSyntax]this.getScrollPosition = getScrollPos;
};

